home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / FileTransfers.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  15.3 KB  |  364 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        FileTransfers.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __FILETRANSFERS__
  18. #define __FILETRANSFERS__
  19.  
  20.  
  21. #ifndef __WINDOWS__
  22. #include <Windows.h>
  23. #endif
  24. /*    #include <Memory.h>                                            */
  25. /*        #include <Types.h>                                        */
  26. /*            #include <ConditionalMacros.h>                        */
  27. /*        #include <MixedMode.h>                                    */
  28. /*    #include <Quickdraw.h>                                        */
  29. /*        #include <QuickdrawText.h>                                */
  30. /*    #include <Events.h>                                            */
  31. /*        #include <OSUtils.h>                                    */
  32. /*    #include <Controls.h>                                        */
  33. /*        #include <Menus.h>                                        */
  34.  
  35. #ifndef __CTBUTILITIES__
  36. #include <CTBUtilities.h>
  37. #endif
  38. /*    #include <Dialogs.h>                                        */
  39. /*        #include <Errors.h>                                        */
  40. /*        #include <TextEdit.h>                                    */
  41. /*    #include <StandardFile.h>                                    */
  42. /*        #include <Files.h>                                        */
  43. /*    #include <AppleTalk.h>                                        */
  44.  
  45. #ifndef __CONNECTIONS__
  46. #include <Connections.h>
  47. #endif
  48.  
  49. #ifndef __TERMINALS__
  50. #include <Terminals.h>
  51. #endif
  52.  
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56.  
  57. #if GENERATINGPOWERPC
  58. #pragma options align=mac68k
  59. #endif
  60.  
  61. #ifdef __CFM68K__
  62. #pragma lib_export on
  63. #endif
  64.  
  65.  
  66. enum {
  67. /* current file transfer manager version    */
  68.     curFTVersion                = 2,
  69. /* FTErr    */
  70.     ftGenericError                = -1,
  71.     ftNoErr                        = 0,
  72.     ftRejected                    = 1,
  73.     ftFailed                    = 2,
  74.     ftTimeOut                    = 3,
  75.     ftTooManyRetry                = 4,
  76.     ftNotEnoughDSpace            = 5,
  77.     ftRemoteCancel                = 6,
  78.     ftWrongFormat                = 7,
  79.     ftNoTools                    = 8,
  80.     ftUserCancel                = 9,
  81.     ftNotSupported                = 10
  82. };
  83.  
  84. typedef OSErr FTErr;
  85.  
  86.  
  87. enum {
  88.     ftIsFTMode                    = 1 << 0,
  89.     ftNoMenus                    = 1 << 1,
  90.     ftQuiet                        = 1 << 2,
  91.     ftConfigChanged                = 1 << 4,
  92.     ftSucc                        = 1 << 7
  93. };
  94.  
  95. typedef unsigned long FTFlags;
  96.  
  97.  
  98. enum {
  99.     ftSameCircuit                = 1 << 0,
  100.     ftSendDisable                = 1 << 1,
  101.     ftReceiveDisable            = 1 << 2,
  102.     ftTextOnly                    = 1 << 3,
  103.     ftNoStdFile                    = 1 << 4,
  104.     ftMultipleFileSend            = 1 << 5
  105. };
  106.  
  107. typedef unsigned short FTAttributes;
  108.  
  109.  
  110. enum {
  111.     ftReceiving,
  112.     ftTransmitting
  113. };
  114.  
  115. typedef unsigned short FTDirection;
  116.  
  117. /*    application routines type definitions */
  118. typedef struct FTRecord FTRecord, *FTPtr, **FTHandle;
  119.  
  120. typedef pascal long (*FileTransferDefProcPtr)(TermHandle hTerm, short msg, long p1, long p2, long p3);
  121. typedef pascal OSErr (*FileTransferReadProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  122. typedef pascal OSErr (*FileTransferWriteProcPtr)(unsigned long *count, Ptr pData, long refCon, short fileMsg);
  123. typedef pascal Size (*FileTransferSendProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags flag);
  124. typedef pascal Size (*FileTransferReceiveProcPtr)(Ptr thePtr, long theSize, long refCon, CMChannel channel, CMFlags *flag);
  125. typedef pascal OSErr (*FileTransferEnvironsProcPtr)(long refCon, ConnEnvironRec *theEnvirons);
  126. typedef pascal void (*FileTransferNotificationProcPtr)(FTHandle hFT, FSSpecPtr pFSSpec);
  127. typedef pascal void (*FileTransferChooseIdleProcPtr)(void);
  128.  
  129. #if GENERATINGCFM
  130. typedef UniversalProcPtr FileTransferDefUPP;
  131. typedef UniversalProcPtr FileTransferReadUPP;
  132. typedef UniversalProcPtr FileTransferWriteUPP;
  133. typedef UniversalProcPtr FileTransferSendUPP;
  134. typedef UniversalProcPtr FileTransferReceiveUPP;
  135. typedef UniversalProcPtr FileTransferEnvironsUPP;
  136. typedef UniversalProcPtr FileTransferNotificationUPP;
  137. typedef UniversalProcPtr FileTransferChooseIdleUPP;
  138. #else
  139. typedef FileTransferDefProcPtr FileTransferDefUPP;
  140. typedef FileTransferReadProcPtr FileTransferReadUPP;
  141. typedef FileTransferWriteProcPtr FileTransferWriteUPP;
  142. typedef FileTransferSendProcPtr FileTransferSendUPP;
  143. typedef FileTransferReceiveProcPtr FileTransferReceiveUPP;
  144. typedef FileTransferEnvironsProcPtr FileTransferEnvironsUPP;
  145. typedef FileTransferNotificationProcPtr FileTransferNotificationUPP;
  146. typedef FileTransferChooseIdleProcPtr FileTransferChooseIdleUPP;
  147. #endif
  148.  
  149. struct FTRecord {
  150.     short                            procID;
  151.     FTFlags                            flags;
  152.     FTErr                            errCode;
  153.     long                            refCon;
  154.     long                            userData;
  155.     FileTransferDefUPP                defProc;
  156.     Ptr                                config;
  157.     Ptr                                oldConfig;
  158.     FileTransferEnvironsUPP            environsProc;
  159.     long                            reserved1;
  160.     long                            reserved2;
  161.     Ptr                                ftPrivate;
  162.     FileTransferSendUPP                sendProc;
  163.     FileTransferReceiveUPP            recvProc;
  164.     FileTransferWriteUPP            writeProc;
  165.     FileTransferReadUPP                readProc;
  166.     WindowPtr                        owner;
  167.     FTDirection                        direction;
  168.     SFReply                            theReply;
  169.     long                            writePtr;
  170.     long                            readPtr;
  171.     char                            *theBuf;
  172.     long                            bufSize;
  173.     Str255                            autoRec;
  174.     FTAttributes                    attributes;
  175. };
  176.  
  177. enum {
  178. /* FTReadProc messages */
  179.     ftReadOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  180.     ftReadDataFork                = 1,
  181.     ftReadRsrcFork                = 2,
  182.     ftReadAbort                    = 3,
  183.     ftReadComplete                = 4,
  184.     ftReadSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  185.     ftReadGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  186. /* FTWriteProc messages */
  187.     ftWriteOpenFile                = 0,                            /* count = forkFlags, buffer = pblock from PBGetFInfo */
  188.     ftWriteDataFork                = 1,
  189.     ftWriteRsrcFork                = 2,
  190.     ftWriteAbort                = 3,
  191.     ftWriteComplete                = 4,
  192.     ftWriteFileInfo                = 5,
  193.     ftWriteSetFPos                = 6,                            /* count = forkFlags, buffer = pBlock same as PBSetFPos */
  194.     ftWriteGetFPos                = 7,                            /* count = forkFlags, buffer = pBlock same as PBGetFPos */
  195. /*    fork flags */
  196.     ftOpenDataFork                = 1,
  197.     ftOpenRsrcFork                = 2
  198. };
  199.  
  200. enum {
  201.     uppFileTransferDefProcInfo = kPascalStackBased
  202.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  203.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(TermHandle)))
  204.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  205.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  206.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long)))
  207.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))),
  208.     uppFileTransferReadProcInfo = kPascalStackBased
  209.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  210.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  211.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  212.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  213.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  214.     uppFileTransferWriteProcInfo = kPascalStackBased
  215.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  216.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned long*)))
  217.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  218.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  219.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  220.     uppFileTransferSendProcInfo = kPascalStackBased
  221.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  222.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  223.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  224.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  225.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  226.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags))),
  227.     uppFileTransferReceiveProcInfo = kPascalStackBased
  228.          | RESULT_SIZE(SIZE_CODE(sizeof(Size)))
  229.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  230.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long)))
  231.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long)))
  232.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(CMChannel)))
  233.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(CMFlags*))),
  234.     uppFileTransferEnvironsProcInfo = kPascalStackBased
  235.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  236.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  237.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ConnEnvironRec*))),
  238.     uppFileTransferNotificationProcInfo = kPascalStackBased
  239.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FTHandle)))
  240.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FSSpecPtr))),
  241.     uppFileTransferChooseIdleProcInfo = kPascalStackBased
  242. };
  243.  
  244. #if GENERATINGCFM
  245. #define NewFileTransferDefProc(userRoutine)        \
  246.         (FileTransferDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferDefProcInfo, GetCurrentArchitecture())
  247. #define NewFileTransferReadProc(userRoutine)        \
  248.         (FileTransferReadUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReadProcInfo, GetCurrentArchitecture())
  249. #define NewFileTransferWriteProc(userRoutine)        \
  250.         (FileTransferWriteUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferWriteProcInfo, GetCurrentArchitecture())
  251. #define NewFileTransferSendProc(userRoutine)        \
  252.         (FileTransferSendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferSendProcInfo, GetCurrentArchitecture())
  253. #define NewFileTransferReceiveProc(userRoutine)        \
  254.         (FileTransferReceiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, GetCurrentArchitecture())
  255. #define NewFileTransferEnvironsProc(userRoutine)        \
  256.         (FileTransferEnvironsUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, GetCurrentArchitecture())
  257. #define NewFileTransferNotificationProc(userRoutine)        \
  258.         (FileTransferNotificationUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, GetCurrentArchitecture())
  259. #define NewFileTransferChooseIdleProc(userRoutine)        \
  260.         (FileTransferChooseIdleUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo, GetCurrentArchitecture())
  261. #else
  262. #define NewFileTransferDefProc(userRoutine)        \
  263.         ((FileTransferDefUPP) (userRoutine))
  264. #define NewFileTransferReadProc(userRoutine)        \
  265.         ((FileTransferReadUPP) (userRoutine))
  266. #define NewFileTransferWriteProc(userRoutine)        \
  267.         ((FileTransferWriteUPP) (userRoutine))
  268. #define NewFileTransferSendProc(userRoutine)        \
  269.         ((FileTransferSendUPP) (userRoutine))
  270. #define NewFileTransferReceiveProc(userRoutine)        \
  271.         ((FileTransferReceiveUPP) (userRoutine))
  272. #define NewFileTransferEnvironsProc(userRoutine)        \
  273.         ((FileTransferEnvironsUPP) (userRoutine))
  274. #define NewFileTransferNotificationProc(userRoutine)        \
  275.         ((FileTransferNotificationUPP) (userRoutine))
  276. #define NewFileTransferChooseIdleProc(userRoutine)        \
  277.         ((FileTransferChooseIdleUPP) (userRoutine))
  278. #endif
  279.  
  280. #if GENERATINGCFM
  281. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  282.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferDefProcInfo, (hTerm), (msg), (p1), (p2), (p3))
  283. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  284.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReadProcInfo, (count), (pData), (refCon), (fileMsg))
  285. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  286.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferWriteProcInfo, (count), (pData), (refCon), (fileMsg))
  287. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  288.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferSendProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  289. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  290.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferReceiveProcInfo, (thePtr), (theSize), (refCon), (channel), (flag))
  291. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  292.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferEnvironsProcInfo, (refCon), (theEnvirons))
  293. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  294.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferNotificationProcInfo, (hFT), (pFSSpec))
  295. #define CallFileTransferChooseIdleProc(userRoutine)        \
  296.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFileTransferChooseIdleProcInfo)
  297. #else
  298. #define CallFileTransferDefProc(userRoutine, hTerm, msg, p1, p2, p3)        \
  299.         (*(userRoutine))((hTerm), (msg), (p1), (p2), (p3))
  300. #define CallFileTransferReadProc(userRoutine, count, pData, refCon, fileMsg)        \
  301.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  302. #define CallFileTransferWriteProc(userRoutine, count, pData, refCon, fileMsg)        \
  303.         (*(userRoutine))((count), (pData), (refCon), (fileMsg))
  304. #define CallFileTransferSendProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  305.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  306. #define CallFileTransferReceiveProc(userRoutine, thePtr, theSize, refCon, channel, flag)        \
  307.         (*(userRoutine))((thePtr), (theSize), (refCon), (channel), (flag))
  308. #define CallFileTransferEnvironsProc(userRoutine, refCon, theEnvirons)        \
  309.         (*(userRoutine))((refCon), (theEnvirons))
  310. #define CallFileTransferNotificationProc(userRoutine, hFT, pFSSpec)        \
  311.         (*(userRoutine))((hFT), (pFSSpec))
  312. #define CallFileTransferChooseIdleProc(userRoutine)        \
  313.         (*(userRoutine))()
  314. #endif
  315.  
  316. extern pascal FTErr InitFT(void);
  317. extern pascal Handle FTGetVersion(FTHandle hFT);
  318. extern pascal short FTGetFTVersion(void);
  319. extern pascal FTHandle FTNew(short procID, FTFlags flags, FileTransferSendUPP sendProc, FileTransferReceiveUPP recvProc, FileTransferReadUPP readProc, FileTransferWriteUPP writeProc, FileTransferEnvironsUPP environsProc, WindowPtr owner, long refCon, long userData);
  320. extern pascal void FTDispose(FTHandle hFT);
  321. extern pascal FTErr FTStart(FTHandle hFT, FTDirection direction, const SFReply *fileInfo);
  322. extern pascal FTErr FTAbort(FTHandle hFT);
  323. extern pascal FTErr FTSend(FTHandle hFT, short numFiles, FSSpecArrayPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  324. extern pascal FTErr FTReceive(FTHandle hFT, FSSpecPtr pFSSpec, FileTransferNotificationUPP notifyProc);
  325. extern pascal void FTExec(FTHandle hFT);
  326. extern pascal void FTActivate(FTHandle hFT, Boolean activate);
  327. extern pascal void FTResume(FTHandle hFT, Boolean resume);
  328. extern pascal Boolean FTMenu(FTHandle hFT, short menuID, short item);
  329. extern pascal short FTChoose(FTHandle *hFT, Point where, FileTransferChooseIdleUPP idleProc);
  330. extern pascal void FTEvent(FTHandle hFT, const EventRecord *theEvent);
  331. extern pascal Boolean FTValidate(FTHandle hFT);
  332. extern pascal void FTDefault(Ptr *theConfig, short procID, Boolean allocate);
  333. extern pascal Handle FTSetupPreflight(short procID, long *magicCookie);
  334. extern pascal void FTSetupSetup(short procID, const void *theConfig, short count, DialogPtr theDialog, long *magicCookie);
  335. extern pascal Boolean FTSetupFilter(short procID, const void *theConfig, short count, DialogPtr theDialog, EventRecord *theEvent, short *theItem, long *magicCookie);
  336. extern pascal void FTSetupItem(short procID, const void *theConfig, short count, DialogPtr theDialog, short *theItem, long *magicCookie);
  337. extern pascal void FTSetupXCleanup(short procID, const void *theConfig, short count, DialogPtr theDialog, Boolean OKed, long *magicCookie);
  338. extern pascal void FTSetupPostflight(short procID);
  339. extern pascal Ptr FTGetConfig(FTHandle hFT);
  340. extern pascal short FTSetConfig(FTHandle hFT, const void *thePtr);
  341. extern pascal OSErr FTIntlToEnglish(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  342. extern pascal OSErr FTEnglishToIntl(FTHandle hFT, const void *inputPtr, Ptr *outputPtr, short language);
  343. extern pascal void FTGetToolName(short procID, Str255 name);
  344. extern pascal short FTGetProcID(ConstStr255Param name);
  345. extern pascal void FTSetRefCon(FTHandle hFT, long refCon);
  346. extern pascal long FTGetRefCon(FTHandle hFT);
  347. extern pascal void FTSetUserData(FTHandle hFT, long userData);
  348. extern pascal long FTGetUserData(FTHandle hFT);
  349. extern pascal void FTGetErrorString(FTHandle hFT, short id, Str255 errMsg);
  350.  
  351. #ifdef __CFM68K__
  352. #pragma lib_export off
  353. #endif
  354.  
  355. #if GENERATINGPOWERPC
  356. #pragma options align=reset
  357. #endif
  358.  
  359. #ifdef __cplusplus
  360. }
  361. #endif
  362.  
  363. #endif /* __FILETRANSFERS__ */
  364.